
import socket
import socketserver

class Handler(socketserver.BaseRequestHandler):
    def handle(self) -> None:
        # self.request is the TCP socket connected to the client
        self.data = self.request.recv(1024).strip()
        print("{} wrote:".format(self.client_address[0]))
        print(self.data)
        # just send back the same data, but upper-cased
        # self.request.sendall("c:/User/ming/Desktop/".encode(encoding='utf-8')+self.data)
        self.request.sendall(self.data)


if __name__ == "__main__":
    HOST, PORT = "localhost", 7000

    # Create the server, binding to localhost on port 9999
    with socketserver.TCPServer((HOST, PORT), Handler) as server:
        # Activate the server; this will keep running until you
        # interrupt the program with Ctrl-C
        server.serve_forever()
